#!/usr/bin/make -f

export PATH := /tmp/go/bin:$(PATH)
export SHELL := env PATH=$(PATH) /bin/bash

export DH_OPTIONS
export DH_GOPKG := github.com/GoogleCloudPlatform/osconfig
export DH_GOLANG_EXCLUDES := e2e_tests/
export CGO_ENABLED := 0
export GO111MODULE := on
export GOPROXY := https://proxy.golang.org
export GOCACHE := /tmp/.cache

%:
	dh $@  --buildsystem=golang --with=golang,systemd

override_dh_auto_install:
	# Binary-only package.
	dh_auto_install -- --no-source
	mv debian/google-osconfig-agent/usr/bin/osconfig debian/google-osconfig-agent/usr/bin/google_osconfig_agent
	install -d debian/google-osconfig-agent/etc/osconfig
	install -d debian/google-osconfig-agent/lib/systemd/system
	install -p -m 0644 *.service debian/google-osconfig-agent/lib/systemd/system/

override_dh_golang:
	# We don't use any packaged dependencies, so skip dh_golang step.

override_dh_auto_test:
	# Skip tests as they are already setup as part of the commit process.

override_dh_auto_build:
	dh_auto_build -O--buildsystem=golang -- -ldflags="-s -w -X main.version=$(VERSION)-$(RELEASE)" -mod=readonly

override_dh_installinit:

override_dh_systemd_start:
	dh_systemd_start --no-restart-after-upgrade --no-restart-on-upgrade
